package
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.media.Sound;
	import flash.display.NativeWindow;
	
	public class SoundBoard extends Sprite
	{
		public var redButton:MovieClip;
		public var yellowButton:MovieClip;
		public var greenButton:MovieClip;
		public var blueButton:MovieClip;
		public var closeButton:MovieClip;
		
		private var buttons:Array=[];
		private var sounds:Array=[];
		private var window:NativeWindow;
		
		public function SoundBoard()
		{
			window=this.stage.nativeWindow;
			sounds=[new buzz(), new Cua_Cua_Cua(), new rimshot(), new cricket()];
			buttons=[redButton,yellowButton,greenButton,blueButton];
			
			for each(var button:MovieClip in buttons)
			{
				button.buttonMode=true;
				button.addEventListener(MouseEvent.CLICK, buttonClicked);
			}
			
			window.stage.addEventListener(MouseEvent.MOUSE_DOWN, movie_mouseDown);
			
			closeButton.visible=false;
			closeButton.buttonMode=true;
			closeButton.addEventListener(MouseEvent.CLICK, closeButton_click);
		}
		
		public function buttonClicked(event:Event):void
		{
			var button:MovieClip=event.currentTarget as MovieClip;
			
			var index=buttons.indexOf(button);
			
			Sound(sounds[index]).play(0,1);
		}
		
		public function movie_mouseDown(event:Event):void
		{
			window.startMove();
		}
		
		public function closeButton_click(event:Event):void
		{
			window.close();
		}
		
	}
}